import {
	REQ_CANCEL_ACTION,
	SET_REQ_CANCEL,
	SET_REQ_ENQUEUE,
	REQ_ENQUEUE_ACTION
} from '@/utils/Const';
export default {
	namespaced : true,
	state : {
		value : []
	},
	mutations : {
		[SET_REQ_CANCEL] (state) {
			state.value.forEach((reqCancelFn) => reqCancelFn());
			state.value = [];
		},
		[SET_REQ_ENQUEUE] (state, payload) {
			state.value.push(payload);
		}
	},
	actions : {
		[REQ_CANCEL_ACTION] ({ commit }) {
			commit(SET_REQ_CANCEL);
		},
		[REQ_ENQUEUE_ACTION] ({ commit }, payload) {
			commit(SET_REQ_ENQUEUE, payload);
		}
	}
};
